class Admin::ProductParametersController < Admin::AdminController
  before_filter :load_product, :only => [:edit, :update]
  
  filter_access_to :all

  def show
    redirect_to :action => :edit
  end

  def edit
    add_crumb("Správa výrobků", admin_products_path)
    add_crumb("Editace výrobku", edit_admin_product_path(params[:product_id]))
    add_crumb("Volitelné parametry")
  end

  def update
    if @product.update_attribute(:parameter_ids, params[:parameter][:id])
      redirect_to edit_admin_product_product_parameters_path(:product_id => params[:product_id]), :notice => "Volitelné parametry byly upraveny."
    else
      render :action => :edit
    end
  end

  private
  def load_product
    @product = Product.find(params[:product_id])
  end
end
